package com.diyunapp.xilinapp.selfdefine;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;


import com.diyunapp.xilinapp.R;
import com.diyunapp.xilinapp.utils.FormatConfirm;

import java.lang.reflect.Field;

public class StatusBarActivity extends Activity {
	
	//状态栏高度
	int  sbar = 0;
	Class<?> c = null;
	Object obj = null;
	Field field = null;
	int x = 0;
	
	private TextView menu_title_tv;
	private ImageButton menu_back_bt;
	private ImageButton menu_menu_bt;
	private View statusbar_view;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
    	try
        {
    	    c = Class.forName("com.android.internal.R$dimen");
    	    obj = c.newInstance();
    	    field = c.getField("status_bar_height");
    	    x =Integer.parseInt(field.get(obj).toString());
    	    sbar = getResources().getDimensionPixelSize(x);
    	}
        catch(Exception e1)
    	{
    	    e1.printStackTrace();
    	}
        
    	if (android.os.Build.VERSION.SDK_INT > 18) 
        {
			Window window = getWindow();
			window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
							WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
			
			/*window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
							WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);*/

			// 创建状态栏的管理实例
			SystemBarTintManager tintManager = new SystemBarTintManager(this);
			// 激活状态栏设置  屏幕顶端
			tintManager.setStatusBarTintEnabled(true);
			// 激活导航栏设置  屏幕底端
			//tintManager.setNavigationBarTintEnabled(true);
			// 设置一个颜色给系统栏
			tintManager.setTintColor(getResources().getColor(R.color.domain_orange));
		}
	}
	
	protected void MenuWidget(View myView)
	{
		//解决状态栏占空的问题
	    if (android.os.Build.VERSION.SDK_INT > 18)
	    {
	    	statusbar_view = (View)myView.findViewById(R.id.actionbar_status_bar);
			statusbar_view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,sbar));
	    	statusbar_view.setVisibility(View.VISIBLE);
		}
	}
}
